﻿add_namespace = CentralAfrica
add_namespace = CentralAfricaNews

### Central African civil war cleanup events ###

#Give the winner CAR cosmetic tag
country_event = {
	id = CentralAfrica.0
	
	hidden = yes
	
	trigger = {
		has_start_date > 2016.1.1
		OR = {
			AND = {
				tag = CAR
				NOT = {
					country_exists = BAL 
					country_exists = SEL
				}
			}
			AND = {
				tag = BAL
				NOT = {
					country_exists = CAR 
					country_exists = SEL
				}
			}
			AND = {
				tag = SEL
				NOT = {
					country_exists = CAR 
					country_exists = BAL
				}
			}
			AND = {
				tag = LOG
				OR = {
					NOT = { country_exists = CAR }
					CAR = { is_subject_of = LOG }
				}
				OR = {
					NOT = { country_exists = SEL }
					SEL = { is_subject_of = LOG }
				}
				OR = {
					NOT = { country_exists = BAL }
					BAL = { is_subject_of = LOG }
				}
			}
		}
		NOT = { has_global_flag = CAR_Civil_War_Over }
	}
	
	mean_time_to_happen = {
		days = 2
	}
	
	immediate = {
		#Civil war is over
		set_global_flag = CAR_Civil_War_Over
		#Clear core status
		324 = {
			remove_core_of = CAR
			remove_core_of = BAL
			remove_core_of = SEL
		}
		325 = {
			remove_core_of = CAR
			remove_core_of = BAL
			remove_core_of = SEL
		}
		921 = {
			remove_core_of = CAR
			remove_core_of = BAL
			remove_core_of = SEL
		}
		922 = {
			remove_core_of = CAR
			remove_core_of = BAL
			remove_core_of = SEL
		}
		#Make the winner Central African Republic
		if = {
			limit = {
				OR = {
					tag = BAL
					tag = SEL
				}
			}
			set_cosmetic_tag = CAR
		}
		if = {
			limit = { NOT = { tag = LOG } }
			add_state_core = 324
			add_state_core = 325
			add_state_core = 921
			add_state_core = 922
			set_capital = 324
		}
		if = {
			limit = {
				has_start_date > 1.1.2001
			}
			news_event = { id = CentralAfricaNews.1 hours = 6 }
		}
	}
	
	option = {
		name = CentralAfrica.0.a
		log = "[GetDateText]: [This.GetName]: CentralAfrica.0.a executed"
	}
}

#Recreate Central African Republic in case it has been annexed
country_event = {
	id = CentralAfrica.1
	
	hidden = yes
	
	trigger = {
		NOT = {
			country_exists = CAR
			country_exists = SEL
			country_exists = BAL
		}
		NOT = { 324 = { is_core_of = CAR } }
	}
	
	mean_time_to_happen = {
		days = 2
	}
	
	immediate = {
		#Clear core status
		324 = {
			remove_core_of = CAR
			remove_core_of = BAL
			remove_core_of = SEL
		}
		325 = {
			remove_core_of = CAR
			remove_core_of = BAL
			remove_core_of = SEL
		}
		921 = {
			remove_core_of = CAR
			remove_core_of = BAL
			remove_core_of = SEL
		}
		922 = {
			remove_core_of = CAR
			remove_core_of = BAL
			remove_core_of = SEL
		}
		CAR = {
			add_state_core = 324
			add_state_core = 325
			add_state_core = 921
			add_state_core = 922
			set_capital = 324
		}
	}
	option = {
		name = CentralAfrica.1.a
		log = "[GetDateText]: [This.GetName]: CentralAfrica.1.a executed"
	}
}
	
#Ending on Central African Civil War
news_event = {

	id = CentralAfricaNews.1
	title = CentralAfricaNews.1.t
	desc = {
		text = CentralAfricaNews.1.CAR.d
		trigger = { FROM = { original_tag = CAR } }
	}
	desc = {
		text = CentralAfricaNews.1.SEL.d
		trigger = { FROM = { original_tag = SEL } }
	}
	desc = {
		text = CentralAfricaNews.1.BAL.d
		trigger = { FROM = { original_tag = BAL } }
	}
	desc = {
		text = CentralAfricaNews.1.LOG.d
		trigger = { FROM = { original_tag = LOG } }
	}
	
	picture = GFX_news_central_african_civil_war
	
	major = yes
	
	is_triggered_only = yes
	
	option = {
		name = CentralAfricaNews.1.a
		log = "[GetDateText]: [This.GetName]: CentralAfricaNews.1.a executed"
		ai_chance = { factor = 100 }
	}
	
}